<template>
  <div class="pageFooter" :class="[$isIos() == 'IOS' ? 'ios' : '']">
    <div class="left_btn_list">
      <button
        class="item"
        type="default"
        :data-name="item.name == '分享' && 'shareBtn'"
        :open-type="item.name == '分享' && 'share'"
        v-for="item in btnList"
        :key="item.name"
        @click="clickItem(item.name)"
      >
        <div class="icon">
          <image class="image" v-if="item.name == '收藏'" :src="issc ? scpng : item.icon" mode="scaleToFill" />
          <image class="image" v-else :src="item.icon" mode="scaleToFill" />
        </div>
        <div class="name">{{ item.name }}</div>
      </button>
    </div>
    <div class="right_submit">
      <div class="btn" @click="$emit('submit')">
        <image class="phone" src="@/static/images/common/phone.png" mode="scaleToFill" />
        <text>{{ btnText }}</text>
      </div>
    </div>
  </div>
</template>

<script>
import scpng from "@/static/images/common/issc.png";
export default {
  name: "pageFooter",
  props: {
    btnText: {
      type: String,
      default: "联系对方",
    },
    btnList: {
      type: Array,
      default() {
        return [
          {
            icon: require("@/static/images/common/sc.png"),
            name: "收藏",
          },
          {
            icon: require("@/static/images/common/share.png"),
            name: "分享",
          },
        ];
      },
    },
    id: {
      type: Number || String,
    },
    data: {
      type: Object,
      default() {
        return {};
      },
    },
    type: {
      type: Number,
      default: 1,
    },
  },
  data() {
    return {
      scpng: scpng,
      // issc: false,
    };
  },
  computed: {
    issc() {
      if (this.data?.is_collect) {
        return this.data.is_collect;
      }
      return false;
    },
  },
  methods: {
    async clickItem(name) {
      switch (name) {
        case "首页":
          uni.redirectTo({
            url: "/pages/index",
          });
          break;
        case "收藏":
          this.$emit("collects", {
            type: this.type, //1 招聘，2简历
            status: !this.issc ? 1 : 2, //1创建，2取消
          });
          break;
        case "分享":
          break;
      }
    },
  },
  watch: {
    id(n, o) {
      console.log("pagefooter", n);
    },
  },

  // 组件周期函数--监听组件挂载完毕
  mounted() {
    // if (this.data && this.data.is_collect) {
    //   this.issc = this.data.is_collect;
    // }
    console.log("this.id", this.id);
  },
  // 组件周期函数--监听组件数据更新之前
  beforeUpdate() {},
  // 组件周期函数--监听组件数据更新之后
  updated() {},
  // 组件周期函数--监听组件激活(显示)
  activated() {},
  // 组件周期函数--监听组件停用(隐藏)
  deactivated() {},
  // 组件周期函数--监听组件销毁之前
  beforeDestroy() {},
};
</script>

<style scoped lang="scss">
.pageFooter {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 60px;
  display: flex;
  align-items: center;
  // justify-content: space-between;
  box-sizing: border-box;
  padding: 9px 15px;
  background: #ffffff;
  // .data-v-e100a550 {
  //   display: none;
  // }
  .left_btn_list {
    display: flex;
    button {
      background: none;
      background-color: none;
      border: none;
      box-shadow: none;
      &::after {
        content: "";
        border: none;
      }
    }
    .item {
      background-color: transparent;

      text-align: center;
      margin-right: 18px;
      padding: 0;
      .icon {
        width: 26px;
        height: 26px;
        .image {
          width: 100%;
          height: 100%;
        }
      }
      .name {
        font-size: 11px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #666666;
      }
    }
  }
  .right_submit {
    position: absolute;
    right: 20px;
    .btn {
      display: flex;
      align-items: center;
      width: 138px;
      height: 42px;
      background: linear-gradient(89deg, #ffa222 0%, #ff8822 100%);
      border-radius: 21px 21px 21px 21px;
      opacity: 1;
      .phone {
        display: inline-block;
        width: 22px;
        height: 22px;
        margin: 0 2px 0 25px;
      }
      text {
        font-size: 16px;
        font-family: PingFang SC-Semibold, PingFang SC;
        font-weight: 600;
        color: #ffffff;
        margin-bottom: 3px;
      }
    }
  }
}
</style>
